import { CsvManager_blxf } from "../Manager/CsvManager";
import { EnumManager_blxf } from "../Manager/EnumManager";
import { ConfigModule_blxf } from "../Module/ConfigModule";
import { NumModule_blxf } from "../Module/NumModule";
import PublicModule_blxf from "../Module/PublicModule";
import { UtilsModule_blxf } from "../Module/UtilsModule";
import { ButtonData_blxf } from "./ButtonData";


/** 摊位数据模型 */
class VendorGameData_blxf {
    public constructor( params: object ) {
        this.isUnlock = true;
        this.vendorId = params['vendorId'];
        this.vendorLv = params['vendorLv'] || 1;
        this.shopList = params['shopList'] || [];

        this.autoShopNum = params['autoShopNum'] || 0;
    }

    /** 摊位id */
    vendorId : number = -1;
    /** 摊位等级 */
    vendorLv : number = 1;
    /** 商品id列表 */
    shopList : number[] = [];
    /** 额外列表 */
    extraList : boolean[] = [];
    // 摊位是否解锁
    isUnlock : boolean = false;

    /** 自动售卖剩余商品数 */
    autoShopNum : number = 0;
}

/** 菜篮子数据模型 */
class TargetGameData_blxf {
    public constructor ( params: object ) {
        this.targetId   = params['targetId'];
        this.targetType = params['targetType'];
        this.targetLv   = params['targetLv'] || 1;
        this.buyShopId  = params['buyShopId'] || -1;
        this.shopNum    = params['shopNum'] || 0;
        this.isUnlock   = params['isUnlock'] || true;
        this.completeNum= params['completeNum'] || 0;
        this.isRandomShopId = params['isRandomShopId'];
    }

    /** 菜篮子id */
    targetId   : number = -1;
    /** 菜篮子等级 */
    targetLv   : number = 0;
    /** 菜篮子类型 */
    targetType : number = -1;
    /** 菜篮子商品id */
    buyShopId  : number = -1;
    /** 菜篮子商品数 */
    shopNum    : number = 0;
    /** 是否解锁 */
    isUnlock   : boolean = true;
    /** 达成次数 */
    completeNum: number = 0;
    /** 是否随机目标商品 */
    isRandomShopId: boolean = true;
}

/** 商品数据模型 */
class ShopGameData_blxf {
    public constructor ( params: object ) {
        this.shopId = params['shopId'];
        this.isNew  = params['isNew'];
    }

    /** 商品id */
    shopId : number = -1;
    /** 是否未查看(新) */
    isNew : boolean = false;
}

/** 客人数据模型 */
class GuestGameData_blxf {
    public constructor ( params: object ) {
        this.guestId = params['guestId'];
        this.isNew   = params['isNew'];
    }

    /** 客人id */
    guestId: number = -1;
    /** 是否未查看(新) */
    isNew : boolean = false;
}

/** 对联数据模型 */
class CoupletGameData_blxf {
    public constructor ( params: object ) {
        this.coupletId = params['coupletId'];
    }

    /** 对联id */
    coupletId : number = -1;
    /** 对联左 */
    leftList  : number[] = [];
    /** 对联右 */
    rightList : number[] = [];
    /** 对联上 */
    topList   : number[] = [];

    /** 是否是新对联 */
    isNew     : boolean = false;

    /**
     * 获取对联类型列表
     * @param type 类型
     * @returns 返回列表
     */
    getList_blxf ( type: number ) {
        let _textList: number[];

        switch( type ) {
            case 1 : _textList = this.leftList; break;
            case 2 : _textList = this.rightList; break;
            case 3 : _textList = this.topList; break;
        }

        return _textList;
    }

    /**
     * 检测是否解锁
     * @param type 类型
     * @param index 下标
     * @returns 
     */
    onCheckUnlock_blxf ( type: number, index: number ) {
        let _isUnlock: boolean;

        let _textList: number[] = this.getList_blxf( type );
        _isUnlock = _textList.includes( index );

        return _isUnlock;
    }

    /**
     * 解锁对联文字
     * @param type 类型 
     * @param index 文字下标
     */
    unlockText_blxf ( type: number, index: number ) {

        let _isCheck: boolean = this.onCheckUnlock_blxf( type, index );
        if ( !_isCheck ) return UtilsModule_blxf.instance.Log_blxf([ `已重复解锁对联文字: `, type, index ]);

        let _textList: number[] = this.getList_blxf( type );
        _textList.push( index );
    }
}

/** 装饰数据模型 */
class DecorationGameData {
    public constructor ( data: any ) {
        this.id = data['id'];
    }

    /** 装饰id */
    id: number = -1;
}


class GridGameData {
    public constructor ( data: any ) {
        this.rowN = data[ 'rowN' ];
        this.colN = data[ 'colN' ];
        this.dataList = data[ 'dataList' ];
    }

    /** 行 */
    rowN: number = -1;
    /** 列 */
    colN: number = -1;

    /** 网格数据 */
    dataList : ButtonData_blxf[] = [];
}


const {ccclass, property} = cc._decorator;


/** 游戏数据存储 */
@ccclass
export default class GameData_blxf {

    private constructor () {

    }
    
    private static _GameData_blxf: GameData_blxf = new GameData_blxf();

    public static get instance () {
        return this._GameData_blxf;
    }

    /** 数据存储属性名 */
    _dataName  : string = 'userData';

    /** 本次进入游戏时间戳 */
    _nowLoginTime : number = 0;

    /** 存档数据：关卡数、大关卡数、金币数、元宝数、摊位数、菜篮子数、客人数、物品数 */
    saveData   : any = null;

    /** 注册时间 */
    userRegisterTime: number = 0;  
    /** 登录时间 */
    userLoginTime   : number = 0;

    /** 大关数 */
    bigPassNum : number = 1;
    /** 关卡数 */
    passNum    : number = 1;
    /** 金币数 */
    goldNum    : number = 0;
    /** 元宝数 */
    diamondNum : number = 0;
    /** 粮票数 */
    paperNum   : number = 0;
    /** 摊位 */
    vendorList : VendorGameData_blxf[] = [];
    /** 菜篮子 */
    targetList : TargetGameData_blxf[] = [];
    /** 商品 */
    shopList   : ShopGameData_blxf[] = [];
    /** 客人 */
    guestList  : GuestGameData_blxf[] = [];
    /** 解锁客人id列表 */
    guestIdList : number[] = [];

    /** 自动售卖菜摊列表 */
    autoVendorList      : VendorGameData_blxf[] = [];
    /** 自动售卖菜篮列表 */
    autoTargetList      : TargetGameData_blxf[] = [];
    /** 自动售卖装饰列表 */
    autoDecorationList  : DecorationGameData[] = [];
    /** 自动售卖奖励数 */
    autoSaleRewardNum   : number = 0;
    /** 自动售卖双倍收益时间 */
    autoDoubleRewardTime: number = 0;
    /** 自动售卖双倍速度时间 */
    autoDoubleSpeedTime : number = 0;

    /** 房间装饰列表 */
    roomDecorationList  : DecorationGameData[] = [];
    /** 厨房装饰列表 */
    kitchenDecorationList : DecorationGameData[] = [];

    /** 对联 */
    coupletList  : CoupletGameData_blxf[] = [];
    /** 使用对联id */
    useCoupletId : number = -1;
    /** 龙等级 */
    dragonLv     : number = 1;
    /** 龙经验 */
    dragonExp    : number = 0;

    /** 新物品id */
    newShopId  : number = -1;
    /** 关卡物品数 */
    passShopNum: number = 0;
    /** 补货剩余库存 */
    btnShopNum : number = 0;
    /** 是否点击返回 */
    isTouchOff : boolean = false;

    /** 是否引导 */
    isGuidance : boolean = false;
    /** 是否引导满商品 */
    isGuidanceAllShop: boolean = false;
    /** 是否引导卸货重装 */
    isGuiRemoveRestart: boolean = false;
    /** 是否引导解锁装饰 */
    isGuidanceBuild: boolean = false;
    /** 是否引导房间装饰 */
    isGuidanceRoomBuild: boolean = false;
    /** 是否弱引导补货 */
    isGuidanceAddShop: boolean = false;

    /** 补货次数 */
    addShopNum: number = 0;
    /** 添加爱心数 */
    addLoveNum: number = 0;

    /** 重置时间 */
    restartTime : string = '';

    isClearShareIdList: boolean = false;
    /** 已分享页面id列表 */
    shareIdList: number[] = [];
    /** 视频id列表 */
    videoIdList: number[] = [];
    /** 已触发负增益大关卡数 */
    negativeBigPassList: number[] = [];

    
    /** 是否引导叠叠乐玩法 */
    isGuidanceJenga: boolean = false;
    /** 关卡分 */
    passScore: number = 0;
    /** 叠叠乐关卡数 */
    jengaPassNum: number = 1;
    /** 菜品素材需求列表 */
    foodItemList: any[] = [];
    /** 已解锁菜品id列表 */
    foodIdList: number[] = [];
    /** 可使用道具次数：[ 消除，换位，刷新 ] */
    propNumList : number[] = [ 0, 0, 0 ];
    /** 网格数据列表 */
    gridDataList: GridGameData[] = [];
    /** 派发数据列表 */
    sendDataList: GridGameData[] = [];
    /** 纽扣物品列表 */
    buttonShopList: any[] = [];

    /** 收集粮票列表 */
    collectPaperList: number[] = [];

    /** 新用户自定义事件上报id列表 */
    reportEventIdList: number[] = [];

    /** 金币不足视频次数 */
    goldVideoNum: number = 2;

    /** 叠叠乐当局观看视频次数 */
    jengaVideoNum: number = 0;

    /** 是否关闭背景音乐 */
    isOffBgm     : boolean = false;
    /** 是否关闭音效 */
    isOffEffect   : boolean = false;
    /** 是否关闭震动 */
    isOffVibrate : boolean = false;

    /** 抖音侧边栏状态 */
    sidebarTTRewardState: number = 0;
    /** 抖音侧边栏奖励更新时间 */
    sidebarTTRewardTime: string = '';

    /** 重置游戏数据 */
    initData_blxf () {
        this.passNum = 1;
        this.goldNum = 0;
        this.diamondNum = 0;

        this.vendorList.length = 0;
        this.targetList.length = 0;
        this.shopList.length = 0;
        this.guestList.length = 0;

        this.newShopId = -1;
        this.passShopNum = 0;
        this.btnShopNum = 0;

        this.isTouchOff = false;
        // this.isGuidance = false;
        // this.isGuidanceAllShop = false;
        
        this.addShopNum = 0;
        this.restartTime = '';
    }

    /** 清除数据 */
    clearData_blxf () {
        let _isInit = this.passNum <= ConfigModule_blxf.basePassNum;
        if ( !_isInit ) return this.restartGameData_blxf();

        cc.sys.localStorage.clear();

        this.initData_blxf();

        // 保存无需重置的数据
        this.saveIsGuidance_blxf();
        this.saveIsGuidanceAllshop_blxf();
        this.saveIsOffBgm_blxf();
        this.saveIsOffEffect_blxf();
        this.saveIsOffVibrate_blxf();
        this.saveReportEventIdList_blxf();
    }

    /** 获取数据 */
    getDataByKey_blxf ( key: string ) {
        let { gameName } = ConfigModule_blxf;
        let _key: string = gameName ? `${gameName}_${key}` : key;
        let _data: string = cc.sys.localStorage.getItem( _key );
        _data = null;
        return _data ? JSON.parse( _data ) : this[key];
    }

    /** 设置数据 */
    setDataByKey_blxf ( key: string, value: any ) {
        let { gameName } = ConfigModule_blxf;
        key = gameName ? `${gameName}_${key}` : key;
        value = JSON.stringify( value );
        // cc.sys.localStorage.setItem( key, value );
    }

    /** 加载游戏数据 */
    async loadGameData_blxf ( cb: any = ()=>{} ) {
        cc.sys.localStorage.clear();

        let _gameDataType = EnumManager_blxf.gameDataType;
        let _vendorListData: any = this.getDataByKey_blxf( _gameDataType.DATA_VENDOR_LIST );
        let _isInitGameData: boolean = _vendorListData && _vendorListData.length == 0;

        let _userData: any = {};
        if ( _isInitGameData && ConfigModule_blxf.gameType == 1 ) {
            let _isString = typeof( _userData ) == 'string';
            if ( _isString ) {
                _isInitGameData = false;
                _userData = JSON.parse(_userData);
                // console.log('获取数据 >>', _userData);
            }
        }

        for ( let key in _gameDataType ) {
            let _propName: string = _gameDataType[ key ];
            let _data: any = _userData[ _propName ] || this.getDataByKey_blxf( _propName);

            // // 初始化游戏默认数据
            // let _isCheckName: boolean = _propName == _gameDataType.DATA_VENDOR_LIST;
            // let _isInitGameData: boolean = _isCheckName && _data.length == 0;
            if ( _isInitGameData ) {
                this.initGameData_blxf(cb);
                break;
            }

            // // 检测小卖部玩法重置游戏时，叠叠乐相关数据跳过
            // if ( PublicModule_blxf.isRestartGame && _isInitGameData ) {
            //     let _isCheckJenga: boolean = this.onCheckJengaData_blxf( _propName );
            //     if ( _isCheckJenga ) continue;
            // }

            if ( !_data ) continue;

            this[ _propName ] = _data;
            this.setDataByKey_blxf( _propName, _data );
        }

        // 兼容，引导未完成清空摊位商品
        let _isGui: boolean = this.getIsGuidance_blxf();
        if ( !_isGui ) {
            this.vendorList.forEach( vendorItem =>{
                vendorItem.shopList.length = 0;
            })
            this.saveVendorData_blxf();

            // 初始化补货数
            this.btnShopNum = 0;
            this.initBtnShopNum_blxf();
        }

        /** 检测每日重置数据 */
        this.onCheckRestartData_blxf();

        this.onCheckLoginTime_blxf();

        cb && cb();
    }

    /** 初始化游戏默认数据 */
    initGameData_blxf ( cb ) {
        // 配置表默认数据 >> 游戏数据 >> 摊位数据
        let { CSV_SHOP, CSV_VENDOR, CSV_TARGET } = EnumManager_blxf.instance.getGameCsvType();
        let _cfgShopData = CsvManager_blxf.instance.getCsvDataByName_blxf( CSV_SHOP );
        let _cfgVendorData = CsvManager_blxf.instance.getCsvDataByName_blxf( CSV_VENDOR );
        let _cfgTargetData = CsvManager_blxf.instance.getCsvDataByName_blxf( CSV_TARGET );

        _cfgShopData.forEach( shopItem => {
            let { ShopId, IsUnlock, NewGuestId } = shopItem;
            if ( IsUnlock != 1 ) return;
            this.unlockShop_blxf( Number(ShopId) );
            this.unlockGuest_blxf( Number(NewGuestId) );
        })

        _cfgVendorData.forEach( vendorItem => {
            let { VendorId, UnlockType } = vendorItem;
            let _vendorId: number = Number(VendorId);

            // TODO特殊处理：重新开始，已解锁视频摊位默认解锁
            let _isUnlock: boolean = PublicModule_blxf.restartBfVendorIdList.includes( _vendorId );
            let _isVideoUnlock: boolean = UnlockType == 9 && _isUnlock;

            (UnlockType == 0 || _isVideoUnlock) && this.unlockVendor_blxf( _vendorId );
        })

        _cfgTargetData.forEach( targetItem => {
            let { TargetId, TargetType, UnlockType } = targetItem;
            if ( UnlockType != 0 ) return;

            let _targetId: number = Number( TargetId );
            let _buyShopId: number = this.shopList[ 0 ].shopId;
            this.unlockTarget_blxf( _targetId, Number(TargetType) );
            this.setTargetShopId_blxf( _targetId, _buyShopId );
        })

        // 初始化补货数
        this.initBtnShopNum_blxf();
        // 初始化注册时间
        this.initRegisterTime_blxf();

        cb && cb();
    }

    /** 初始化补货数 */
    initBtnShopNum_blxf () {
        let { maxVendorNum } = ConfigModule_blxf;
        let { CSV_VENDOR_ADDSHOP } = EnumManager_blxf.instance.getGameCsvType();
        let _cfgVendorAddShopData = CsvManager_blxf.instance.getCsvDataByName_blxf( CSV_VENDOR_ADDSHOP );
        // 初始补货数
        let _vendorNum: number = this.getVendorNum_blxf();
        if ( _vendorNum > maxVendorNum ) _vendorNum = maxVendorNum;
        _cfgVendorAddShopData.forEach( addShopItem =>{
            let { VendorNum, AddShopNum } = addShopItem;
            VendorNum == _vendorNum && this.updateBtnShopNum_blxf( Number(AddShopNum) );
        })
    }

    /** 初始化注册时间 */
    initRegisterTime_blxf () {
        let _userRegisterTime: number = this.getUserRegisterTime_blxf();
        if ( _userRegisterTime ) return;

        this.userRegisterTime = NumModule_blxf.instance.getTime_blxf();
        this.saveUserRegisterTime_blxf();
    }

    /** 检测每日重置数据 */
    onCheckRestartData_blxf () {
        let _isRestartOk: boolean = this.updateRestartTime_blxf();
        if ( !_isRestartOk ) return;

        let _sidebarState: number = this.sidebarTTRewardState;

        if ( _sidebarState != 1 ) {
            this.sidebarTTRewardState = 0;
            this.saveSidebarState_blxf();
        }

        // 金币不足视频次数
        let { goldVideoNum } = ConfigModule_blxf;
        this.goldVideoNum = goldVideoNum;
        this.saveGoldVideoNum_blxf();
    }

    /** 检测登录时间 */
    onCheckLoginTime_blxf () {
        this._nowLoginTime = NumModule_blxf.instance.getTime_blxf();

        let _isNowDay: boolean = UtilsModule_blxf.onCheckNowDay_blxf( this.userLoginTime );
        if ( _isNowDay ) return;

        this.userLoginTime = NumModule_blxf.instance.getTime_blxf();
        this.saveUserLoginTime_blxf();

        this.onClearShareIdList_blxf();
    }

    /** 检测是否是第一次进入游戏 */
    onCheckFirstEntryGame_blxf () {
        let _isFirst: boolean;

        let _time: number = this._nowLoginTime - this.userRegisterTime;
        _isFirst = _time < 3 * 1000;

        return _isFirst;
    }

    // 关卡数据、金币、元宝、摊位、菜篮子、商品、客人

    saveUserRegisterTime_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_USER_REGISTER_TIME, this.userRegisterTime );
    }

    saveUserLoginTime_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_USER_LOGIN_TIME, this.userLoginTime );
    }

    /** 保存金币数 */
    saveGoldNum_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_GOLD_NUM, this.goldNum );
    }

    /** 保存元宝数 */
    saveDiamondNum_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_DIAMOND_NUM, this.diamondNum );
    }

    savePaperNum_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_PAPER_NUM, this.paperNum );
    }

    /** 保存关卡数 */
    savePassNum_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_PASS_NUM, this.passNum );
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_BIG_PASS_NUM, this.bigPassNum );
    }

    /** 关卡物品数 */
    savePassShopNum_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_PASS_SHOP_NUM, this.passShopNum );
    }

    /** 保存摊位数据 */
    saveVendorData_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_VENDOR_LIST, this.vendorList );
    }

    /** 保存菜篮子数据 */
    saveTargetData_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_TARGET_LIST, this.targetList );
    }

    /** 保存商品数据 */
    saveShopData_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_SHOP_LIST, this.shopList );
    }

    /** 保存新商品id */
    saveNewShopId_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_NEW_SHOPID, this.newShopId );
    }

    /** 保存客人数据 */
    saveGuestData_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_GUEST_LIST, this.guestList );
    }

    saveGuestIdData_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_GUEST_ID_LIST, this.guestIdList );
    }

    /** 保存剩余补货数 */
    saveBtnShopNum_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_BTN_SHOP_NUM, this.btnShopNum );
    }

    /** 保存是否点击返回 */
    saveIsTouchOff_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_TOUCH_OFF, this.isTouchOff );
    }

    /** 保存是否引导 */
    saveIsGuidance_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_GUIDANCE, this.isGuidance );
    }

    saveIsGuidanceJenga_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_GUIDANCE_JENGA, this.isGuidanceJenga );
    }

    saveIsGuidanceAllshop_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_GUIDANCE_ALL_SHOP, this.isGuidanceAllShop );
    }

    saveSidebarState_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_TT_SIDEBAR_STATE, this.sidebarTTRewardState );
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_TT_SIDEBAR_TIME, this.sidebarTTRewardTime );
    }

    saveRestartTime_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_RESTART_TIME, this.restartTime );
    }

    saveReportEventIdList_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_REPORT_EVENTID_LIST, this.reportEventIdList );
    }

    setAddShopNum_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_ADD_SHOP_NUM, this.addShopNum );
    }

    saveIsOffBgm_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_OFF_BGM, this.isOffBgm );
    }

    saveIsOffEffect_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_OFF_EFFECT, this.isOffEffect );
    }

    saveIsOffVibrate_blxf () {
        this.setDataByKey_blxf ( EnumManager_blxf.gameDataType.DATA_IS_OFF_VIBRATE, this.isOffVibrate );
    }

    saveIsGuiRemoveRestart_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_GUIDANCE_REMOVE_RESTART, this.isGuiRemoveRestart );
    }

    saveSaveData_blxf () {
        this.setDataByKey_blxf ( EnumManager_blxf.gameDataType.DATA_SAVE_DATA, this.saveData );
    }

    saveAddLoveNum_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_ADD_LOVE_NUM, this.addLoveNum );
    }

    saveCoupletList_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_COUPLET_LIST, this.coupletList );
    }

    saveUseCoupletId_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_USE_COUPLET_ID, this.useCoupletId );
    }

    saveDragonLv_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_DRAGON_LV, this.dragonLv );
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_DRAGON_EXP, this.dragonExp );
    }

    saveAutoVendorData_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_AUTO_VENDOR_LIST, this.autoVendorList );
    }

    saveAutoTargetData_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_AUTO_TARGET_LIST, this.autoTargetList );
    }

    saveAutoDecorationData_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_AUTO_DECORATION_LIST, this.autoDecorationList );
    }

    saveAutoSaleRewardNum_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_AUTO_SALE_REWARD_NUM, this.autoSaleRewardNum );
    }

    savetAutoDoubleRewardTime_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_AUTO_DOUBLE_REWARD_TIME, this.autoDoubleRewardTime );
    }

    saveAutoDoubleSpeedTime_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_AUTO_DOUBLE_SPEED_TIME, this.autoDoubleSpeedTime );
    }

    saveIsGuidanceBuild_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_GUIDANCE_BUILD, this.isGuidanceBuild );
    }

    saveShareIdList_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_SHARE_ID_LIST, this.shareIdList );
    }

    saveVideoIdList_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_VIDEO_ID_LIST, this.videoIdList );
    }

    saveNegativeBigPassList_blxf () {
        this.setDataByKey_blxf ( EnumManager_blxf.gameDataType.DATA_NEGATIVE_BIGPASS_LIST, this.negativeBigPassList );
    }

    saveRoomDecorationData_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_ROOM_DECORATION_LIST, this.roomDecorationList );
    }

    saveKitchenDecorationData_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_KITCHEN_DECORATION_LIST, this.kitchenDecorationList );
    }

    saveIsGuidanceRoomBuild_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_GUIDANCE_ROOM_BUILD, this.isGuidanceRoomBuild );
    }

    saveIsGuidanceAddShop_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_GUIDANCE_ADD_SHOP, this.isGuidanceAddShop );
    }

    saveGoldVideoNum_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_GOLD_VIDEO_NUM, this.goldVideoNum );
    }

    saveJengaPassNum_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_JENGA_PASS_NUM, this.jengaPassNum );
    }

    saveCollectPaperList_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_COLLECT_PAPER_LIST, this.collectPaperList );
    }

    saveJengaVideoNum_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_JENGA_VIDEO_NUM, this.jengaVideoNum );
    }

    /** 获取用户注册时间 */
    getUserRegisterTime_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_USER_REGISTER_TIME );
    }

    /** 获取金币数 */
    getGoldNum_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_GOLD_NUM );
    }

    /** 获取元宝数 */
    getDiamondNum_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_DIAMOND_NUM );
    }

    /** 获取粮票数 */
    getPaperNum_blxf () {
        return this.paperNum;
    }

    /** 获取关卡数 */
    getPassNum_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_PASS_NUM );
    }

    /** 获取大关数 */
    getBigPassNum_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_BIG_PASS_NUM );
    }

    /** 获取关卡商品数 */
    getPassShopNum_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_PASS_SHOP_NUM );
    }

    /** 获取商品列表 */
    getShopList_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_SHOP_LIST );
    }

    /** 获取新商品id */
    getNewShopId_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_NEW_SHOPID );
    }

    /** 获取客人列表（1：主玩法菜摊客人、2：自动售卖装饰客人） */
    getGuestList_blxf ( guestType: number = 1 ) {
        let _unlockGuestList = this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_GUEST_LIST );

        _unlockGuestList = _unlockGuestList.filter( guestItem =>{
            let { guestId } = guestItem;
            let _isCheck1: boolean = guestType == 1 && guestId < 100;
            let _isCheck2: boolean = guestType == 2 && guestId > 100;
            return _isCheck1 || _isCheck2;
        });

        return _unlockGuestList;
    }

    getGuestIdList_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_GUEST_ID_LIST );
    }

    /** 获取剩余补货数 */
    getBtnShopNum_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_BTN_SHOP_NUM );
    }

    /** 获取是否点击返回 */
    getIsTouchOff_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_TOUCH_OFF );
    }

    /** 获取是否引导 */
    getIsGuidance_blxf () {
        // return true;
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_GUIDANCE );
    }

    getIsGuidanceJenga_blxf () {
        return this.isGuidanceJenga;
    }

    getIsGuidanceAllShop_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_GUIDANCE_ALL_SHOP );
    }

    getSidebarState_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_TT_SIDEBAR_STATE );
    }

    getRestartTime_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_RESTART_TIME );
    }

    getReportEventIdList_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_REPORT_EVENTID_LIST );
    }

    getAddShopNum_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_ADD_SHOP_NUM );
    }

    getIsOffBgm_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_OFF_BGM );
    }

    getIsOffEffect_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_OFF_EFFECT );
    }

    getIsOffVibrate_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_OFF_VIBRATE );
    }

    getIsGuiRemoveRestart_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_GUIDANCE_REMOVE_RESTART );
    }

    getSaveData_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_SAVE_DATA );
    }

    getAddLoveNum_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_ADD_LOVE_NUM );
    }

    getCoupletList_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_COUPLET_LIST );
    }

    getUseCoupletId_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_USE_COUPLET_ID );
    }

    getDragonLv_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_DRAGON_LV ) || 1;
    }

    getDragonExp_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_DRAGON_EXP ) || 0;
    }

    getAutoVendorData_blxf ( vendorId: number = null ) {
        let _autoVendorList: any[] = this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_AUTO_VENDOR_LIST );
        
        // 兼容
        _autoVendorList.forEach( vendorItem =>{
            if ( vendorItem['vendorLv'] > ConfigModule_blxf.maxAutoVendorLevel ) {
                vendorItem['vendorLv'] = ConfigModule_blxf.maxAutoVendorLevel;
            }
        })

        if ( !vendorId ) return _autoVendorList;
        
        let _autoVendorData: VendorGameData_blxf = _autoVendorList.find( item => item.vendorId == vendorId );
        if ( _autoVendorData ) return _autoVendorData;
    }

    getAutoTargetData_blxf ( targetId: number = null ) {
        let _autoTargetList: TargetGameData_blxf[] = this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_AUTO_TARGET_LIST );
        
        // 兼容
        _autoTargetList.forEach( targetItem =>{
            if ( targetItem['targetLv'] > ConfigModule_blxf.maxAutoTargetLevel ) {
                targetItem['targetLv'] = ConfigModule_blxf.maxAutoTargetLevel;
            }
        })

        if ( !targetId ) return _autoTargetList;

        let _autoTargetData: TargetGameData_blxf = _autoTargetList.find( item => item.targetId == targetId );
        if ( _autoTargetData ) return _autoTargetData;
    }

    /** 获取装饰数据 */
    getDecorationDataByType_blxf ( type: number = 1, decorationId: number = null ) {
        let _propName: string;
        let { DATA_AUTO_DECORATION_LIST, DATA_ROOM_DECORATION_LIST, DATA_KITCHEN_DECORATION_LIST } = EnumManager_blxf.gameDataType;
        switch ( type ) {
            case 1 : _propName = DATA_AUTO_DECORATION_LIST; break;
            case 2 : _propName = DATA_ROOM_DECORATION_LIST; break;
            case 3 : _propName = DATA_KITCHEN_DECORATION_LIST; break;
        }
        let _decorationList: any[] = this.getDataByKey_blxf( _propName );
        if ( !decorationId ) return _decorationList;

        let _decorationData: DecorationGameData = _decorationList.find( item => item.id == decorationId );
        if ( _decorationData ) return _decorationData;
    }

    getAutoSaleRewardNum_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_AUTO_SALE_REWARD_NUM );
    }

    getAutoDoubleRewardTime_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_AUTO_DOUBLE_REWARD_TIME );
    }

    getAutoDoubleSpeedTime_blxf (){
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_AUTO_DOUBLE_SPEED_TIME );
    }

    getIsGuidanceBuild_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_GUIDANCE_BUILD );
    }

    getIsGuidanceRoomBuild_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_GUIDANCE_ROOM_BUILD );
    }

    getIsGuidanceAddShop_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_IS_GUIDANCE_ADD_SHOP );
    }

    getGoldVideoNum_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_GOLD_VIDEO_NUM );
    }

    /** 获取菜品素材数据 */
    getFoodItemList_blxf ( foodItemId: number = null ) {
        let _foodItemList: any[] = UtilsModule_blxf.instance.getCopyData_blxf( this.foodItemList );
        let _foodItemData: any = _foodItemList.find( item => item.id == foodItemId );
        return foodItemId ? _foodItemData : _foodItemList;
    }

    getFoodIdList_blxf () {
        return UtilsModule_blxf.instance.getCopyData_blxf( this.foodIdList );
    }

    getButtonShopList_blxf () {
        return UtilsModule_blxf.instance.getCopyData_blxf( this.buttonShopList );
    }

    getCollectPaperList_blxf () {
        return UtilsModule_blxf.instance.getCopyData_blxf( this.collectPaperList );
    }

    /** 获取道具数 */
    getPropNumList_blxf ( propId: number = 0 ) {
        let _propNumList: number[] = this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_PROP_NUM_LIST );
        let _isPropId: boolean = propId > 0;
        return _isPropId ? _propNumList[ propId - 1 ] : _propNumList;
    }

    getGridDataList_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_GRID_DATA_LIST );
    }

    getSendDataList_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_SEND_DATA_LIST );
    }

    // /** 获取关卡数 */
    // getPassNum_blxf () {
    //     return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_PASS_NUM );
    // }

    getPassScore_blxf () {
        return this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_PASS_SCORE );
    }
    
    /** 获取叠叠乐玩法关卡数 */
    getJengaPassNum_blxf () {
        return this.jengaPassNum;
    }

    getJengaVideoNum_blxf () {
        return this.jengaVideoNum;
    }

    getButtonShopId_blxf ( buttonId: number ) {
        let _shopId: number;

        let _data: any = this.buttonShopList.find( item =>{
            return item.buttonId == buttonId;
        }) || {};
        _shopId = _data.shopId;

        return _shopId;
    }

    /** 更新重置数据时间 */
    updateRestartTime_blxf () {
        let _isRestartOk: boolean;
        let _timeStr: string = NumModule_blxf.instance.getTimeStr_blxf();
        if ( _timeStr == this.restartTime ) return _isRestartOk;

        this.restartTime = _timeStr;

        this.saveRestartTime_blxf();

        _isRestartOk = true;
        return _isRestartOk;
    }

    /**
     * 更新金币数
     * @param updateNum 变化数
     */
    updateGoldNum_blxf ( updateNum: number ) {
        if ( typeof(updateNum) != 'number' ) {
            return UtilsModule_blxf.instance.Log_blxf(`更新金币参数类型错误！！！`, 2);
        }

        this.goldNum += updateNum;

        if ( this.goldNum < 0 ) {
            this.goldNum = 0;
            UtilsModule_blxf.instance.Log_blxf(`扣除金币数异常！！！`, 2);
        }

        this.saveGoldNum_blxf();
    }

    /**
     * 更新元宝数
     * @param updateNum 变化数 
     */
    updateDiamondNum_blxf ( updateNum: number ) {
        if ( typeof(updateNum) != 'number' ) {
            return UtilsModule_blxf.instance.Log_blxf(`更新元宝参数类型错误！！！`, 2);
        }

        this.diamondNum += updateNum;

        if ( this.diamondNum < 0 ) {
            this.diamondNum = 0;
            UtilsModule_blxf.instance.Log_blxf(`扣除元宝数异常！！！`, 2);
        }

        this.saveDiamondNum_blxf();
    }

    /**
     * 更新粮票数
     * @param updateNum 变化数 
     */
    updatePaperNum_blxf ( updateNum: number ) {
        if ( typeof(updateNum) != 'number' ) {
            return UtilsModule_blxf.instance.Log_blxf(`更新粮票参数类型错误！！！`, 2);
        }

        this.paperNum += updateNum;

        if ( this.paperNum < 0 ) {
            this.paperNum = 0;
            UtilsModule_blxf.instance.Log_blxf(`扣除粮票数异常！！！`, 2);
        }

        this.savePaperNum_blxf();
    }

    /** 解锁摊位 */
    unlockVendor_blxf ( vendorId: number ) {
        if ( !vendorId ) return;

        let _vendorIndex: number = this.vendorList.findIndex( item => item.vendorId == vendorId );
        if ( _vendorIndex != -1 ) return this.setVendorIsUnlock_blxf( vendorId, true );

        let _vendorData: VendorGameData_blxf = new VendorGameData_blxf({ vendorId });
        this.vendorList.push( _vendorData );

        this.saveVendorData_blxf();
    }

    /** 解锁菜篮子 */
    unlockTarget_blxf ( targetId: number, targetType: number ) {
        if ( !targetId || !targetType ) return;
        
        let _targetData: TargetGameData_blxf = new TargetGameData_blxf({ targetId, targetType });
        this.targetList.push( _targetData );

        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_TARGET_LIST, this.targetList );
    }

    /** 解锁商品 */
    unlockShop_blxf ( shopId: number ) {
        if ( !shopId ) return;

        let isNew: boolean = ![ 10000, 10001 ].includes( shopId );
        let _shopData: ShopGameData_blxf = new ShopGameData_blxf({ shopId, isNew });
        this.shopList.push( _shopData );

        this.saveShopData_blxf();

        let _newShopId: number = this.getNewShopId_blxf();
        _newShopId == -1 && this.setNewShopId_blxf( shopId );
    }

    /** 解锁客人 */
    unlockGuest_blxf ( guestId: number ) {
        if ( !guestId ) return;

        if ( this.onIsUnlockGuest_blxf( guestId ) ) return;

        let isNew: boolean = ![  ].includes( guestId );
        let _guestData: GuestGameData_blxf = new GuestGameData_blxf({ guestId, isNew });
        this.guestList.push( _guestData );

        this.saveGuestData_blxf();
    }

    unlockGuestId_blxf ( guestId: number ) {
        if ( !guestId ) return;

        let _isCheck: boolean = this.onCheckGuestId_blxf( guestId );
        if ( _isCheck ) return;

        this.guestIdList.push( guestId );
        
        this.saveGuestIdData_blxf();
    }

    updateNewGuest_blxf ( guestId: number ) {
        let _guestData: GuestGameData_blxf = this.guestList.find( guestItem =>{
            return guestItem.guestId == guestId;
        })
        if ( !_guestData ) return;

        _guestData.isNew = false;

        this.saveGuestData_blxf();
    }

    /** 检测客人id是否解锁 */
    onCheckGuestId_blxf ( guestId: number ) {
        let _isCheck: boolean = this.guestIdList.includes( guestId );

        return _isCheck;
    }

    /**
     * 获取摊位数据
     * @param vendorId 摊位id
     * @returns 返回摊位数据
     */
    getVendorData_blxf ( vendorId: number = -1 ) {
        let _vendorData: VendorGameData_blxf;
        let _vendorList: VendorGameData_blxf[] = this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_VENDOR_LIST );

        let _isAll: boolean = vendorId == -1;
        if ( !_isAll ) {
            let _vendorIndex: number = this.getVendorIndex_blxf( vendorId );
            if ( _vendorIndex >= 0 ) _vendorData = _vendorList[ _vendorIndex ];
        }

        return _isAll ? _vendorList : _vendorData;
    }

    /** 获取已解锁摊位数 */
    getVendorNum_blxf () {
        let _vendorList: any = this.getVendorData_blxf();
        _vendorList = _vendorList.filter( item => item.vendorId != 5 );
        let _vendorNum: number = _vendorList.length;

        return _vendorNum;
    }

    /** 获取摊位下标 */
    getVendorIndex_blxf ( vendorId: number ) {
        let _vendorIndex: number = this.vendorList.findIndex( item => item.vendorId == vendorId );
        if ( _vendorIndex != -1 ) {
            let { isUnlock } = this.vendorList[ _vendorIndex ];
            return isUnlock || vendorId != 5 ? _vendorIndex : -1;
        }
        // UtilsModule_blxf.instance.Log_blxf(`获取摊位下标失败 vendorId => ${vendorId}`, 2);
        return -1;
    }

    /** 设置摊位商品数据 */
    setVendorShopList_blxf ( vendorId: number, shopList: number[], extraList: boolean[] ) {
        let _vendorIndex: number = this.vendorList.findIndex( item => item.vendorId == vendorId );
        this.vendorList[ _vendorIndex ].shopList = shopList;
        this.vendorList[ _vendorIndex ].extraList = extraList;

        this.saveVendorData_blxf();
    }

    /** 设置摊位等级 */
    setVendorLv_blxf ( vendorId: number, addLv: number ) {
        let _vendorIndex: number = this.getVendorIndex_blxf( vendorId );
        if ( _vendorIndex == -1 ) return;

        this.vendorList[ _vendorIndex ].vendorLv = this.vendorList[ _vendorIndex ].vendorLv || 0;
        this.vendorList[ _vendorIndex ].vendorLv += addLv;

        this.saveVendorData_blxf();
    }

    /** 获取摊位等级 */
    getVendorLv_blxf ( vendorId: number ) {
        // 兼容老用户，默认1级
        let _vendorLv: number = 1;

        let _vendorIndex: number = this.getVendorIndex_blxf( vendorId );
        if ( _vendorIndex == -1 ) return _vendorLv;

        _vendorLv = this.vendorList[ _vendorIndex ].vendorLv || 1; 
        return _vendorLv;
    }

    /**
     * 设置摊位是否解锁
     * @param vendorId 摊位id
     * @param isUnlock 是否解锁
     */
    setVendorIsUnlock_blxf ( vendorId: number, isUnlock: boolean ) {
        let _vendorIndex: number = this.vendorList.findIndex( item => item.vendorId == vendorId );
        if ( _vendorIndex == -1 ) return;

        this.vendorList[ _vendorIndex ].isUnlock = isUnlock;

        this.saveVendorData_blxf();
    }

    /**
     * 获取菜篮子数据
     * @param targetId 菜篮子id
     * @returns 菜篮子数据
     */
    getTargetData_blxf ( targetId: number = -1 ) {
        let _targetData: TargetGameData_blxf;
        let _targetList: TargetGameData_blxf[] = this.getDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_TARGET_LIST );

        let _isAll: boolean = targetId == -1;
        if ( !_isAll ) {
            let _targetIndex: number = this.getTargetIndex_blxf( targetId );
            if ( _targetIndex >= 0 ) _targetData = _targetList[ _targetIndex ];
        }

        return _isAll ? _targetList : _targetData;
    }

    /**
     * 获取已解锁菜篮子数
     * @returns 返回菜篮子数
     */
    getTargetNum_blxf () {
        let _targetNum: number = 0;

        this.targetList.forEach( targetItem =>{
            let { targetId } = targetItem;
            if ( targetId == 1 ) return;
            _targetNum += 1;
        })

        return _targetNum;
    }

    /** 获取菜篮子下标 */
    getTargetIndex_blxf ( targetId: number ) {
        let _targetIndex: number = this.targetList.findIndex( item => item.targetId == targetId );
        if ( _targetIndex != -1 ) return _targetIndex;
        // UtilsModule_blxf.instance.Log_blxf(`获取菜篮子下标失败 targetId => ${targetId}`, 2);

        return -1;
    }

    /** 设置菜篮子等级 */
    setTargetLv_blxf ( targetId: number ) {
        let _targetIndex: number = this.getTargetIndex_blxf( targetId );
        if ( _targetIndex == -1 ) return;

        this.targetList[ _targetIndex ].targetLv += 1;
        this.targetList[ _targetIndex ].completeNum = 0;

        this.saveTargetData_blxf();
    }

    /** 设置菜篮子信息 */
    setTargetInfo_blxf ( targetId: number, targetInfo: any ) {
        let _targetIndex: number = this.getTargetIndex_blxf( targetId );
        if ( _targetIndex == -1 ) return;

        let { isUnlock, buyShopId, buyShopNum, isRandomShopId } = targetInfo;
        this.targetList[ _targetIndex ].isUnlock = isUnlock;
        this.targetList[ _targetIndex ].shopNum = buyShopNum;
        this.targetList[ _targetIndex ].buyShopId = buyShopId;
        this.targetList[ _targetIndex ].isRandomShopId = isRandomShopId;

        this.saveTargetData_blxf();
    }

    /** 设置菜篮子商品id */
    setTargetShopId_blxf ( targetId: number, shopId: number ) {
        let _targetIndex: number = this.getTargetIndex_blxf( targetId );
        if ( _targetIndex == -1 ) return;

        this.targetList[ _targetIndex ].buyShopId = shopId;

        this.saveTargetData_blxf();
    }

    /** 设置菜篮子达成次数 */
    setTargetCompleteNum_blxf ( targetId: number ) {
        let _targetIndex: number = this.getTargetIndex_blxf( targetId );
        if ( _targetIndex == -1 ) return;

        this.targetList[ _targetIndex ].completeNum += 1;

        this.saveTargetData_blxf();
    }

    /** 获取菜篮子达成次数 */
    getTargetCompleteNum_blxf ( targetId: number ) {
        let _targetIndex: number = this.getTargetIndex_blxf( targetId );
        if ( _targetIndex == -1 ) return;

        let { completeNum } = this.targetList[ _targetIndex ];
        return completeNum;
    }

    /** 获取已解锁商品id列表 */
    getShopIdList_blxf () {
        let _shopIdList: number[] = [];

        this.shopList.forEach( shopItem =>{
            _shopIdList.push( shopItem.shopId );
        })

        return _shopIdList;
    }

    /** 设置新物品状态 */
    setIsNewShop_blxf ( shopId: number ) {
        let _index: number = this.shopList.findIndex( shopItem =>{
            return shopItem.shopId == shopId;
        })
        if ( _index == -1 ) return;

        this.shopList[ _index ].isNew = false;

        this.saveShopData_blxf();
    }

    /** 设置新商品id */
    setNewShopId_blxf ( newShopId: number = -1 ) {
        this.newShopId = newShopId;

        this.saveNewShopId_blxf();
    }

    /**
     * 设置关卡物品信息
     * @param passShopNum 关卡商品数
     * @param isPass 是否过关
     */
    setPassShopNum_blxf ( passShopNum: number, isPass: boolean = false ) {
        this.passShopNum = passShopNum;
        this.savePassShopNum_blxf();

        if ( isPass ) {
            let { basePassNum } = ConfigModule_blxf;
            this.passNum += 1;
            this.bigPassNum = Math.ceil( this.passNum / basePassNum );
            this.savePassNum_blxf();

            // this.passNum % basePassNum == 1 && setTimeout(()=>{
            //     this.setSaveData_blxf();
            // }, 110);
        }
    }

    setBigPassNum_blxf () {
        let { basePassNum } = ConfigModule_blxf;
        this.bigPassNum = Math.ceil( this.passNum / basePassNum );
        this.savePassNum_blxf();

        this.passNum % basePassNum == 1 && this.setSaveData_blxf();
    }

    /**
     * 检测客人是否解锁
     * @param guestId 客人id
     */
    onIsUnlockGuest_blxf ( guestId: number ) {
        let _guestData: GuestGameData_blxf = this.guestList.find( guestItem =>{
            return guestItem.guestId == guestId;
        })

        let _isUnlock: boolean = !!_guestData;

        return _isUnlock;
    }

    onIsNewGuest_blxf ( guestId: number ) {
        let _isNew: boolean = false;

        let _guestData: GuestGameData_blxf = this.guestList.find( guestItem =>{
            return guestItem.guestId == guestId;
        })
        if ( !_guestData ) return _isNew;

        _isNew = _guestData.isNew
        return _isNew;
    }

    /**
     * 更新剩余补货数
     * @param updateNum 变化值: 正加负减
     */
    updateBtnShopNum_blxf ( updateNum: number ) {
        this.btnShopNum += updateNum;
        
        if ( this.btnShopNum < 0 ) {
            this.btnShopNum = 0;
        }

        this.saveBtnShopNum_blxf();
    }

    /**
     * 设置是否点击返回
     * @param isTouch 是否点击返回
     */
    setIsTouchOff_blxf ( isTouch: boolean ) {
        this.isTouchOff = isTouch;

        this.saveIsTouchOff_blxf();
    }

    /** 设置引导状态 */
    setIsGuidance_blxf () {
        this.isGuidance = true;
        
        this.saveIsGuidance_blxf();
    }

    /** 设置叠叠乐引导状态 */
    setIsGuidanceJenga_blxf () {
        this.isGuidanceJenga = true;

        this.saveIsGuidanceJenga_blxf();
    }

    /** 设置满物品引导状态 */
    setIsGuidanceAllShop_blxf () {
        this.isGuidanceAllShop = true;
        
        this.saveIsGuidanceAllshop_blxf();
    }

    /** 设置是否引导卸货重开 */
    setIsGuiRemoveStart_blxf () {
        this.isGuiRemoveRestart = true;

        this.saveIsGuiRemoveRestart_blxf();
    }

    /** 增加补货次数 */
    addShopNum_blxf () {
        this.addShopNum += 1;
        
        this.setAddShopNum_blxf();
    }

    /** 添加爱心数 */
    addLoveNum_blxf () {
        this.addLoveNum += 1;
        this.saveAddLoveNum_blxf();
    }


    findCoupletData_blxf ( coupletId: number ) {
        let _coupletData: CoupletGameData_blxf = this.coupletList.find( item => {
            return item.coupletId == coupletId;
        })

        return _coupletData;
    }

    /**
     * 解锁对联文字
     * @param coupletId 对联id 
     * @param coupletType 对联类型
     * @param textIndex 文字下标
     */
    unlockCouplet_blxf ( coupletId: number, coupletType: number, textIndex: number ) {
        let _coupletData: CoupletGameData_blxf = this.findCoupletData_blxf( coupletId );

        if ( !_coupletData ) {
            _coupletData = new CoupletGameData_blxf( { coupletId } );
            this.coupletList.push( _coupletData );
        }

        switch ( coupletType ) {
            case 1 : _coupletData.leftList.push( textIndex ); break;
            case 2 : _coupletData.rightList.push( textIndex ); break;
            case 3 : _coupletData.topList.push( textIndex ); break;
        }

        // todo test
        // this.coupletList[0].rightList.length = 6;

        this.saveCoupletList_blxf();
    }

    /** 检测对联解锁状态 */
    onCheckCouplet_blxf ( coupletId: number, coupletType: number, textIndex: number ) {
        let _isUnlockText: boolean = false;

        let _coupletData: CoupletGameData_blxf = this.coupletList.find( item => {
            return item.coupletId == coupletId;
        })
        if ( !_coupletData ) return _isUnlockText;

        let _textList: number[];
        switch( coupletType ) {
            case 1 : _textList = _coupletData.leftList; break;
            case 2 : _textList = _coupletData.rightList; break;
            case 3 : _textList = _coupletData.topList; break;
        }

        _isUnlockText = _textList.includes( textIndex );
        return _isUnlockText;
    }

    /**
     * 检测对联状态
     * @param coupletId 对联id
     */
    onCheckCoupletState_blxf ( coupletId: number, isCheck: boolean ) {
        let _coupletData: CoupletGameData_blxf = this.findCoupletData_blxf( coupletId );
        if ( !_coupletData && isCheck ) return;

        let { coupletNumList } = ConfigModule_blxf;
        let _unList: number[][] = [];
        let _i: number, _j: number, _numLen: number = coupletNumList.length - 1;
        for ( _i = 0; _i < _numLen; _i++ ) {
            let _coupletType: number = _i + 1;
            _unList[ _i ] = _unList[ _i ] || [];

            let _maxNum = coupletNumList[ _i ];
            for ( _j = 0; _j < _maxNum; _j++ ) {
                let _textIndex: number = _j;
                let _isUnlock: boolean = this.onCheckCouplet_blxf( coupletId, _coupletType, _textIndex );
                if ( _isUnlock ) continue;

                _unList[ _i ].push( _textIndex );
            }
        }

        return _unList;
    }

    /** 更新使用的对联id */
    updateUseCoupletId_blxf ( coupletId: number ) {
        this.useCoupletId = coupletId;

        this.updateCoupletNewState_blxf( coupletId, false );

        this.saveUseCoupletId_blxf();
    }

    /** 更新对联 */
    updateCoupletNewState_blxf ( coupletId: number, isNew: boolean ) {
        let _coupletData: CoupletGameData_blxf = this.findCoupletData_blxf( coupletId );
        if ( !_coupletData ) return;

        _coupletData.isNew = isNew;

        this.saveCoupletList_blxf();
    }

    /** 更新龙相关数据 */
    updateDragonData ( isLv: boolean ) {
        if ( isLv ) {
            this.dragonLv += 1;
            this.dragonExp = 0;
        } else {
            this.dragonExp += 1;
        }

        this.saveDragonLv_blxf();
    }

    /** 设置是否关闭背景 */
    setIsOffBgm_blxf ( isOff: boolean ) {
        this.isOffBgm = isOff;
        this.saveIsOffBgm_blxf();
    }

    /** 设置是否关闭音效 */
    setIsOffEfeect_blxf ( isOff: boolean ) {
        this.isOffEffect = isOff;
        this.saveIsOffEffect_blxf();
    }

    /** 设置是否关闭震动 */
    setIsOffVibrate_blxf ( isOff: boolean ) {
        this.isOffVibrate = isOff;
        this.saveIsOffVibrate_blxf();
    }

    getJengaData_blxf () {
        let {
            DATA_IS_GUIDANCE_JENGA,
            DATA_PASS_SCORE,
            DATA_JENGA_PASS_NUM,
            DATA_FOOD_ITEM_LIST,
            DATA_FOOD_ID_LIST,
            DATA_PROP_NUM_LIST,
            DATA_GRID_DATA_LIST,
            DATA_SEND_DATA_LIST,
            DATA_BUTTON_SHOP_LIST,
            DATA_COLLECT_PAPER_LIST,
            DATA_JENGA_VIDEO_NUM,
            DATA_KITCHEN_DECORATION_LIST
        } = EnumManager_blxf.gameDataType;

        let _jengaDataNameList: string[] = [
            DATA_IS_GUIDANCE_JENGA,
            DATA_PASS_SCORE,
            DATA_JENGA_PASS_NUM,
            DATA_FOOD_ITEM_LIST,
            DATA_FOOD_ID_LIST,
            DATA_PROP_NUM_LIST,
            DATA_GRID_DATA_LIST,
            DATA_SEND_DATA_LIST,
            DATA_BUTTON_SHOP_LIST,
            DATA_COLLECT_PAPER_LIST,
            DATA_JENGA_VIDEO_NUM,
            DATA_KITCHEN_DECORATION_LIST
        ]

        return _jengaDataNameList;
    }

    /** 检测是否是叠叠乐玩法数据 */
    onCheckJengaData_blxf ( checkName: string ) {
        let _jengaDataNameList: string[] = this.getJengaData_blxf();
        let _isCheck: boolean = _jengaDataNameList.includes( checkName );
        return _isCheck;
    }

    /** 小卖部存档数据：关卡数、大关卡数、金币数、元宝数、摊位数、菜篮子数、客人数、物品数 */
    setSaveData_blxf () {
        let {
            DATA_BIG_PASS_NUM,
            DATA_PASS_NUM,
            DATA_PASS_SHOP_NUM,
            DATA_GOLD_NUM,
            DATA_DIAMOND_NUM,
            DATA_VENDOR_LIST,
            DATA_TARGET_LIST,
            DATA_GUEST_LIST,
            DATA_SHOP_LIST,
            DATA_AUTO_DECORATION_LIST,
            DATA_BTN_SHOP_NUM,
            DATA_AUTO_VENDOR_LIST,
            DATA_AUTO_TARGET_LIST,
            DATA_AUTO_SALE_REWARD_NUM,
            DATA_ROOM_DECORATION_LIST,
        } = EnumManager_blxf.gameDataType;

        let _saveData: any = {};
        _saveData[ DATA_BIG_PASS_NUM ] = this[ DATA_BIG_PASS_NUM ];
        _saveData[ DATA_PASS_NUM ] = this[ DATA_PASS_NUM ];
        _saveData[ DATA_PASS_SHOP_NUM ] = this[ DATA_PASS_SHOP_NUM ];
        _saveData[ DATA_GOLD_NUM ] = this[ DATA_GOLD_NUM ];
        _saveData[ DATA_DIAMOND_NUM ] = this[ DATA_DIAMOND_NUM ];
        _saveData[ DATA_VENDOR_LIST ] = this[ DATA_VENDOR_LIST ];
        _saveData[ DATA_TARGET_LIST ] = this[ DATA_TARGET_LIST ];
        _saveData[ DATA_GUEST_LIST ] = this[ DATA_GUEST_LIST ];
        _saveData[ DATA_SHOP_LIST ] = this[ DATA_SHOP_LIST ];
        _saveData[ DATA_BTN_SHOP_NUM ] = this[ DATA_BTN_SHOP_NUM ];

        _saveData[ DATA_AUTO_VENDOR_LIST ] = this[ DATA_AUTO_VENDOR_LIST ];
        _saveData[ DATA_AUTO_TARGET_LIST ] = this[ DATA_AUTO_TARGET_LIST ];
        _saveData[ DATA_AUTO_SALE_REWARD_NUM ] = this[ DATA_AUTO_SALE_REWARD_NUM ];
        _saveData[ DATA_AUTO_DECORATION_LIST ] = this[ DATA_AUTO_DECORATION_LIST ];

        _saveData[ DATA_ROOM_DECORATION_LIST ] = this[ DATA_ROOM_DECORATION_LIST ];

        this.saveData = Object.assign( this.saveData || {}, _saveData );
        this.saveData = UtilsModule_blxf.instance.getCopyData_blxf( _saveData );

        this.saveSaveData_blxf();

        this.bigPassNum > 1 && this.setUserData_blxf();
    }

    /** 叠叠乐玩法存档数据 */
    setSaveJengaData_blxf () {
        let _saveData: any = {};

        /** 叠叠乐玩法相关数据 */
        let _jengaDataNameList: string[] = this.getJengaData_blxf();
        _jengaDataNameList.forEach( itemName =>{
            _saveData[ itemName ] = this[ itemName ];
        })

        this.saveData = Object.assign( this.saveData || {}, _saveData );
        this.saveData = UtilsModule_blxf.instance.getCopyData_blxf( _saveData );

        this.saveSaveData_blxf();

        this.jengaPassNum > 1 && this.setUserData_blxf();
    }

    /** 保存数据至服务器 */
    setUserData_blxf () {
        let _userData: any = {};

        let { DATA_TT_SIDEBAR_STATE, DATA_TT_SIDEBAR_TIME } = EnumManager_blxf.gameDataType;
        let _checkList: string[] = [ DATA_TT_SIDEBAR_STATE, DATA_TT_SIDEBAR_TIME ];
        for ( let key in EnumManager_blxf.gameDataType ) {
            let _dataKey: string = EnumManager_blxf.gameDataType[ key ];
            if ( _checkList.includes( _dataKey ) ) continue;

            let _dataValue: any = this[ _dataKey ];
            _userData[ _dataKey ] = _dataValue;
        }

        _userData = JSON.stringify( _userData );
        // console.log('setUserData_blxf >>', _userData);
    }

    /** 重置游戏数据 */
    restartGameData_blxf () {
        if ( !this.saveData ) return;

        for (let saveKey in this.saveData ) {
            this[ saveKey ] = this.saveData[ saveKey ];
        }

        this.savePassNum_blxf();
        this.savePassShopNum_blxf();
        this.saveGoldNum_blxf();
        this.saveDiamondNum_blxf();
        this.saveVendorData_blxf();
        this.saveTargetData_blxf();
        this.saveGuestData_blxf();
        this.saveShopData_blxf();
        this.saveBtnShopNum_blxf();
        this.saveAutoVendorData_blxf();
        this.saveAutoTargetData_blxf();
        this.saveAutoSaleRewardNum_blxf();
        this.saveAutoDecorationData_blxf();
        this.saveRoomDecorationData_blxf();
    }

    /**
     * 上报事件id
     * @param eventId 事件id
     */
    addReportEventId_blxf ( eventId: number ) {
        this.reportEventIdList.push( eventId );

        this.saveReportEventIdList_blxf();
    }

    /***  ======= 设置平台字段 ======= */


    /** 设置侧边栏状态 0：初始值、1：可领取、2：已领取 */
    setSidebarTTRewardState_blxf ( state: number ) {
        let _state: number = this.getSidebarState_blxf();
        UtilsModule_blxf.instance.Log_blxf(`state, _state =1> ${state}, ${_state}`, -1);

        if ( state == 1 && _state != 0 ) return;
        if ( state == 2 && _state != 1 ) return;

        this.sidebarTTRewardState = state;
        if ( state == 1 ) {
            this.sidebarTTRewardTime = NumModule_blxf.instance.getTimeStr_blxf();
        }
        this.saveSidebarState_blxf();
    }

    /** 检测是否领取侧边栏奖励 */
    isReceiveSidebarReward_blxf () {
        let _isReceive: boolean = this.sidebarTTRewardState == 2;

        return _isReceive;
    }




    /** 解锁自动售卖菜摊 */
    unlockAutoVendor_blxf ( vendorId: number, autoShopNum: number ) {
        let _vendorIndex: number = this.autoVendorList.findIndex( item => item.vendorId == vendorId );
        if ( _vendorIndex != -1 ) return;

        let _vendorData: VendorGameData_blxf = new VendorGameData_blxf({ vendorId, autoShopNum });
        this.autoVendorList.push( _vendorData );

        this.saveAutoVendorData_blxf();
    }

    /** 解锁自动售卖菜篮 */
    unlockAutoTarget_blxf ( targetId: number ) {
        let _targetIndex: number = this.autoTargetList.findIndex( item => item.targetId == targetId );
        if ( _targetIndex != -1 ) return;

        let _targetData: TargetGameData_blxf = new TargetGameData_blxf({ targetId });
        this.autoTargetList.push( _targetData );

        this.saveAutoTargetData_blxf();
    }

    /** 解锁自动售卖装饰 */
    unlockAutoDecoration_blxf ( id: number ) {
        let _decorationIndex: number = this.autoDecorationList.findIndex( item => item.id == id );
        if ( _decorationIndex != -1 ) return;

        let _decorationData: DecorationGameData = new DecorationGameData({ id });
        this.autoDecorationList.push( _decorationData );

        this.saveAutoDecorationData_blxf();
    }

    /** 解锁房间内部装饰 */
    unlockRoomDecoration_blxf ( id: number ) {
        let _decorationIndex: number = this.roomDecorationList.findIndex( item => item.id == id );
        if ( _decorationIndex != -1 ) return;

        let _decorationData: DecorationGameData = new DecorationGameData({ id });
        this.roomDecorationList.push( _decorationData );

        this.saveRoomDecorationData_blxf();
    }

    /** 解锁厨房内部装饰 */
    unlockKitchenDecoration_blxf ( id: number ) {
        let _decorationIndex: number = this.kitchenDecorationList.findIndex( item => item.id == id );
        if ( _decorationIndex != -1 ) return;

        let _decorationData: DecorationGameData = new DecorationGameData({ id });
        this.kitchenDecorationList.push( _decorationData );

        this.saveKitchenDecorationData_blxf();
    }

    /** 设置自动售卖菜摊等级 */
    setAutoVendorLevel_blxf ( vendorId: number, addLv: number = 1 ) {
        let _vendorIndex: number = this.autoVendorList.findIndex( item => item.vendorId == vendorId )
        if ( _vendorIndex == -1 ) return;

        this.autoVendorList[ _vendorIndex ].vendorLv += addLv;
        this.saveAutoVendorData_blxf();
    }

    /** 设置自动售卖菜篮等级 */
    setAutoTargetLevel_blxf ( targetId: number, addLv: number = 1 ) {
        let _targetIndex: number = this.autoTargetList.findIndex( item => item.targetId == targetId );
        if ( _targetIndex == -1 ) return;

        this.autoTargetList[ _targetIndex ].targetLv += addLv;
        this.saveAutoTargetData_blxf();
    }

    /** 设置自动售卖菜摊商品数 */
    setAutoVendorShopNum_blxf ( vendorId: number, autoShopNum: number ) {
        let _vendorIndex: number = this.autoVendorList.findIndex( item => item.vendorId == vendorId )
        if ( _vendorIndex == -1 ) return;

        this.autoVendorList[ _vendorIndex ].autoShopNum += autoShopNum;
        this.saveAutoVendorData_blxf();
    }

    /** 扣除客人购买商品数（暂时调用） */
    updateAutoVendorShopNum_blxf ( _autoShopNum: number ) {
        let _index: number, _vendorId: number = -1;

        let _indexList: number[] = [];
        this.autoVendorList.forEach( (item, index) =>{
            let { autoShopNum } = item;
            if ( autoShopNum < Math.abs(_autoShopNum) ) return;
            
            _indexList.push( index );
        })

        if ( _indexList.length == 0 ) return;

        _indexList.sort((a, b) => Math.random() - 0.5);
        
        _index = _indexList[0];
        _vendorId = this.autoVendorList[ _index ].vendorId;

        this.autoVendorList[ _index ].autoShopNum += _autoShopNum;
        this.saveAutoVendorData_blxf();

        return _vendorId;
    }

    /** 获取已解锁菜摊商品总数 */
    getAutoVendorTotalShopNum_blxf () {
        let _autoShopTotalNum: number = 0;

        this.autoVendorList.forEach( item =>{
            _autoShopTotalNum += item.autoShopNum;
        })

        return _autoShopTotalNum;
    }

    /** 设置自动售卖奖励数 */
    setAutoSaleRewardNum_blxf ( updateNum: number ) {

        this.autoSaleRewardNum += updateNum;
        if ( this.autoSaleRewardNum < 0 ) this.autoSaleRewardNum = 0;
        this.saveAutoSaleRewardNum_blxf();
    }

    /** 获取自动售卖菜篮等级 */
    getAutoTargetLevel_blxf ( targetId: number ) {
        let _autoTargetData: any = this.getAutoTargetData_blxf( targetId );
        let { targetLv } = _autoTargetData || { targetLv: 1 };
        
        return targetLv;
    }

    /** 获取自动售卖菜摊等级 */
    getAutoVendorLevel_blxf ( vendorId: number ) {
        let _autoVendorData: any = this.getAutoVendorData_blxf( vendorId );
        let { vendorLv } = _autoVendorData || { targetLv: 1 };

        return vendorLv;
    }

    /** 更新双倍奖励时间 */
    updateAutoDoubleRewardTime_blxf ( updateNum: number ) {
        this.autoDoubleRewardTime += updateNum;

        this.savetAutoDoubleRewardTime_blxf();
    }

    /** 更新双倍速度时间 */
    updateAutoDoubleSpeedTime_blxf ( updateNum: number ) {
        this.autoDoubleSpeedTime += updateNum;

        this.saveAutoDoubleSpeedTime_blxf();
    }

    /** 设置已引导解锁装饰 */
    setIsGuidanceBuild_blxf () {
        this.isGuidanceBuild = true;

        this.saveIsGuidanceBuild_blxf();
    }

    /** 设置是否引导房间装饰 */
    setIsGuidanceRoomBuild_blxf () {
        this.isGuidanceRoomBuild = true;

        this.saveIsGuidanceRoomBuild_blxf();
    }

    /** 设置是否引导补货 */
    setIsGuidanceAddShop_blxf () {
        this.isGuidanceAddShop = true;

        this.saveIsGuidanceAddShop_blxf();
    }

    /** 检测是否已分享 */
    onCheckShareId_blxf ( shareId: number ) {
        // APP/抖音：默认已分享
        let _isTT: boolean = ConfigModule_blxf.isTtPlatform_blxf();
        let _isApp: boolean = ConfigModule_blxf.isAppPlatform_blxf();
        if ( _isTT || _isApp ) return true;

        let _isShare: boolean = this.shareIdList.includes( shareId );
        let _isNewUser: boolean = UtilsModule_blxf.onCheckNewUser_blxf();
        if ( _isNewUser && !_isShare && shareId != 3 ) {
            _isShare = !this.onCheckVideoId_blxf( shareId );
        }

        return _isShare;
    }

    /** 检测是否已视频 */
    onCheckVideoId_blxf ( shareId: number ) {
        let _isVideo: boolean = this.videoIdList.includes( shareId );

        return _isVideo;
    }

    /** 设置分享id */
    setShareIdList_blxf ( shareId: number ) {
        let _isShare: boolean = this.onCheckShareId_blxf( shareId );
        if ( _isShare ) return;

        this.shareIdList.push( shareId );
        this.saveShareIdList_blxf();

        UtilsModule_blxf.instance.onInitBuffData_blxf();
    }

    /** 设置视频id */
    setVideoIdList_blxf ( shareId: number ) {
        let _isVideo: boolean = this.onCheckVideoId_blxf( shareId );
        if ( _isVideo ) return;

        this.videoIdList.push( shareId );
        this.saveVideoIdList_blxf();
    }
    
    // 清除分享id
    onClearShareIdList_blxf () {
        this.shareIdList = [];
        this.saveShareIdList_blxf();
    }

    /** 检测负增益大关数 */
    onCheckNegativeBigPassList_blxf ( bigPassNum: number ) {
        let _isCheck: boolean = this.negativeBigPassList.includes( bigPassNum );

        return _isCheck;
    }

    /** 设置负增益大关数 */
    setNegativeBigPassList_blxf ( bigPassNum: number ) {
        let _isCheck: boolean = this.onCheckNegativeBigPassList_blxf( bigPassNum );
        if ( _isCheck ) return;

        this.negativeBigPassList.push( bigPassNum );
        this.saveNegativeBigPassList_blxf();
    }


    // 注意：todo test method
    setPassNum_test_blxf () {
        let { basePassNum } = ConfigModule_blxf;
        this.passNum = 200;
        this.bigPassNum = Math.ceil( this.passNum / basePassNum );
        this.savePassNum_blxf();
    }

    /** 更新金币视频次数 */
    updateGoldVideoNum_blxf () {
        if ( this.goldVideoNum <= 0 ) return;

        this.goldVideoNum -= 1;
        this.saveGoldVideoNum_blxf();
    }

    saveFoodItemList_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_FOOD_ITEM_LIST, this.foodItemList );
    }

    setFoodItemList_blxf ( itemId: number, num: number, maxNum: number ) {
        let _index: number = this.foodItemList.findIndex( item => item.id == itemId );
        if ( _index > -1 ) {
            this.foodItemList[ _index ].num += num;
        } else {
            _index = this.foodItemList.length;
            this.foodItemList.push({ id: itemId, num });
        }

        if ( this.foodItemList[ _index ].num >= maxNum ) {
            this.foodItemList[ _index ].num = maxNum;
        }

        this.saveFoodItemList_blxf();
    }

    saveFoodIdList_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_FOOD_ID_LIST, this.foodIdList );
    }

    /** 设置菜品id列表 */
    setFoodIdList_blxf ( foodId: number ) {
        if ( !foodId ) return;

        this.foodIdList.push( foodId );
        this.saveFoodIdList_blxf();
    }

    saveButtonShopList_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_BUTTON_SHOP_LIST, this.buttonShopList );
    }

    setButtonShopList_blxf ( dataList: any[] ) {
        if ( this.buttonShopList.length > 0 ) return;
        
        this.buttonShopList = dataList;

        this.saveButtonShopList_blxf();
    }

    /** 设置叠叠乐关卡数 */
    setJengaPassNum_blxf () {
        this.jengaPassNum += 1;
        this.saveJengaPassNum_blxf();
    }

    setJengaVideoNum_blxf () {
        this.jengaVideoNum += 1;
        this.saveJengaVideoNum_blxf();
    }

    /** 保存道具次数列表 */
    setPropNumList_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_PROP_NUM_LIST, this.propNumList );
    }

    /** 更新道具数 */
    setPropNum_blxf ( propId: number, updateNum: number ) {
        let _propNum: number = this.propNumList[ propId - 1 ] || 0;
        if ( updateNum < 0 && _propNum <= 0 ) return;
        
        this.propNumList[ propId - 1 ] = this.propNumList[ propId - 1 ] || 0;
        this.propNumList[ propId - 1 ] += updateNum;
        this.setPropNumList_blxf();
        // cc.log('setPropNum_blxf >>', propId, updateNum, this.propNumList[ propId - 1 ]);
    }

    /** 保存网格数据列表 */
    setGridDataList_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_GRID_DATA_LIST, this.gridDataList );
    }

    setSendDataList_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_SEND_DATA_LIST, this.sendDataList );
    }

    setPassScore_blxf () {
        this.setDataByKey_blxf( EnumManager_blxf.gameDataType.DATA_PASS_SCORE, this.passScore );
    }

    /** 保存数据列表 */
    setGridData_blxf ( gridData: any ) {
        let { rowN, colN, dataList } = gridData;
        let _index: number = this.gridDataList.findIndex( item => {
            return item.rowN == rowN && item.colN == colN;
        })
        if ( _index == -1 ) {
            this.gridDataList.push( new GridGameData( gridData ) );
        } else {
            this.gridDataList[ _index ].dataList = dataList;
        }
        this.setGridDataList_blxf();
    }

    /** 保存派发数据 */
    setSendData_blxf ( index: number, dataList: any[] ) {
        let _sendData: any = this.sendDataList[ index ];
        if ( !_sendData ) {
            this.sendDataList.push( new GridGameData( { rowN: 0, colN: index, dataList }));
        } else {
            this.sendDataList[ index ].dataList = dataList;
        }
        this.setSendDataList_blxf();
    }

    clearGridData_blxf () {
        this.passScore = 0;
        this.jengaVideoNum = 0;
        this.foodItemList.length = 0;
        this.gridDataList.length = 0;
        this.sendDataList.length = 0;
        this.buttonShopList.length = 0;
        this.setGridDataList_blxf();
        this.setSendDataList_blxf();
        this.setPassScore_blxf();
        this.saveJengaVideoNum_blxf();
        this.saveFoodItemList_blxf();
    }

    updatePassScore_blxf ( addScore: number ) {
        this.passScore += addScore;
        this.setPassScore_blxf();
    }

    /** 设置已领取收集粮票 */
    setCollectPaperList_blxf ( collectId: number ) {
        if ( this.onCheckCollectPaper_blxf( collectId ) ) return;
        
        this.collectPaperList.push( collectId );

        this.saveCollectPaperList_blxf();
    }

    /** 检测是否已领取收集奖励 */
    onCheckCollectPaper_blxf ( collectId: number ) {
        let _isCheck: boolean = this.collectPaperList.includes( Number(collectId) );
        return _isCheck;
    }

}
